class Solution {
public:
    bool _isSymmetrical(TreeNode* leftnode, TreeNode* rightnode)
    {
        if (!leftnode && !rightnode)
            return true;
        else if ((!leftnode && rightnode) || (leftnode && !rightnode))
            return false;
        return (leftnode->val == rightnode->val) && _isSymmetrical(leftnode->left, rightnode->right) && _isSymmetrical(leftnode->right, rightnode->left);
    }
    bool isSymmetrical(TreeNode* pRoot) {
        if (!pRoot)
            return true;
        return _isSymmetrical(pRoot->left, pRoot->right);
    }
};